<?php
/**
 * Created by PhpStorm.
 * User: idcu
 * Date: 2016/3/11
 * Time: 10:54
 */
namespace Service\Controller;
use Think\Controller;

class CenterController extends Controller
{
    public function index(){
        $req = I('param.');
        $tel = $req['tel'];
        $data_tel = D('Customer')->where(array('tel'=>$tel))->relation(array('families','orders'))->select();
        $data_contact = D('Customer')->where(array('contact'=>array('like','%'.$tel.'%')))->relation(array('families','orders'))->select();
        if($data_tel){
            $data_tel[0]['primary'] = 1;
        }
        $data = array_merge($data_tel,$data_contact);
//        $data = D('Customer')->relation(true)->select();

        $this->assign('data',$data);
        dump($data);
        $this->display();
    }

    public function choice(){
        $req = I('param.');
        $param['tel'] = $req['tel'];
        $param['name'] = $req['name'];

        $customer = D('Customer')->where($param)->relation('families')->select();
        $this->assign('customer',$customer);
        $this->display();
    }
}